package cn.xuewenbao.ucenter.controller;


import cn.xuewenbao.ucenter.entity.vo.BlackUserVo;
import cn.xuewenbao.ucenter.entity.vo.BlackVo;
import cn.xuewenbao.ucenter.service.BlackListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 黑名单 前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-06-08
 */
@RestController
@RequestMapping("/ucenter/black")
@Api(tags = "黑名单")
public class BlackListController {

    @Autowired
    private BlackListService blackListService;

    //拉黑某用户
    @ApiOperation(value = "拉黑某用户")
    @PostMapping("addBlack")
    public Result<Boolean> addBlack(@RequestBody BlackVo blackVo) {
        Result<Boolean> result = blackListService.addBlack(blackVo);
        return result;
    }

    //获取黑名单列表
    @ApiOperation(value = "获取黑名单列表")
    @GetMapping("getBlackList/{userId}")
    public Result<List<BlackUserVo>> getBlackList(@PathVariable String userId) {
        Result<List<BlackUserVo>> result = blackListService.getBlackList(userId);
        return result;
    }

    //取消拉黑某用户
    @ApiOperation(value = "取消拉黑某用户")
    @PostMapping("removeBlack")
    public Result<Boolean> removeBlack(@RequestBody BlackVo blackVo) {
        Result<Boolean> result = blackListService.removeBlack(blackVo);
        return result;
    }
}

